import requests
import execjs


file = open('MusicCode.js',encoding='utf-8').read()
js_file = execjs.compile(file)
res = js_file.call('aaa')
# print(res)


cookies = {
    '_ntes_nuid': '399b5e331ec0413c5455353f1046477d',
    '_iuqxldmzr_': '32',
    'NMTID': '00OxQ0tD40btpDpiEN5qEuGUwKrZnkAAAGAfcSJcg',
    'WEVNSM': '1.0.0',
    'WNMCID': 'ikvmkb.1651377473502.01.0',
    'WM_TID': '9FGbvXH8HeJFEQFVFQLFAG6joCCF2%2Bp%2B',
    '_ntes_nnid': '399b5e331ec0413c5455353f1046477d,1694477914286',
    'ntes_utid': 'tid._.dNI4KmkFtAhAVlARUALQyZF5oUMNPBCs._.0',
    'sDeviceId': 'YD-xxC57qOxaZ9ER1VVVBaRmV%2FBVOKVmHQ%2F',
    '__snaker__id': 'NC0ojMWDUQmkBJm2',
    'ntes_kaola_ad': '1',
    '__csrf': '402eea0fef99183f935a2f8ee3da18d7',
    '__csrf': '3a3f7ea42a8cb890c88e96b81dfbfe4b',
    'MUSIC_U': '00AB1E0AA4CF807D344FAB25217502B73ED7A250C14DADF268E81455A1462D48A33A19E89CFE16C3E2A0F33C8FA62C643DD0D6AF1D135DF786A6530BA94B4012DDF28DCD60DD8407CB4D82FE4618CEDF80A505534B23FEB060359292BBF065EFB42D1CC8BD2C44F19B2D7C6506D19EE841DCBDC09FDAC8BF353C8CE734F4801BF201F34AE3F40CE112E3DE36F64C07B9F1A050A4CAD9FC0CE6F9ABFB6FD33561930D7A7BC74A43EB6FA7404074709EE6BFDEFF0B3B5305250D2FC6351FE299B62D63A4C378FE8122EB85D010A2EF478D1CE0A264D7431EE1C9692F0212E22172EA328885AF2B00F91A92124154F1A870299591B8E83A934511D786BA2F5775377EEFD486009018B99E41712A19873A0847BC51E888DB44D2A37A554DE554A8FA5E78034D09DCABC96619382546CA96EF3C70D03F156F9FE21CB50CE66F0B3B49694802D8A72332F63D47547C13622ECC4FCC1F66C9F8D152AFF629116D9E20DED456EADDDFD2A7E9984A38BCBD0EAD6A25',
    'gdxidpyhxdE': '5hpRbSBHDoQhpWQ%2Bhe01CX0N%2B5M5tiUAWgw%5Cz%5C%2B1GCkTXAmcxaCtPMhfjOKZu%2BZlBgHgOkqKNhyy9bh%5C5QA%2FGfD%2B6X9Q9Xsr4cqeE9wX%2BMQQe0VGhYZOq2E8hu4Vu%2FE8WARcZQo8MgsCwcE1sYPgULNiEyLq%2BvLuAt%5CPBriqjUoCMxoa%3A1723273134032',
    'WM_NI': 'YQNVwo63RLwulcNO9NreUOOTYDlodVZyKI8npBS2pkWCe3KFyX1xPrye70Oz7eMymT3F8EEBuFtR5%2FJGh1UZimFQuGOBCfWYAxpupJOKnndZucZoCz90MJH86yvb4sPcT2Y%3D',
    'WM_NIKE': '9ca17ae2e6ffcda170e2e6ee8dd872ba968bccaa7090868fa3c45f829e8e87cb5eab9e8eadf44392aba9a9f82af0fea7c3b92a9b8f82b7f665f6ed9eadf67fb0bd82b0bc46b2bb9bb0ce609b9ca490e75e9aa785aabb66b49e9dd3f361959dabd4ca4ebb88ff99d37abbbbf9d1ce72f5bb839af060f19af8a6c84ab79abcb3b8258a99a8d2d852abb38ab2f84d8d9e8d87d65383a8c096f3428d95a28fe752b7bd9690c272fbf083abcb34f6a7ba83b77994bd9cd3dc37e2a3',
    'JSESSIONID-WYYY': 'UnFqYjUFTeO4jjrb3T5ml1CFqSnpH3nuyH2rR5gSDS3szWl2%2F0DZSE3%2FQuBF4KjAmnovnMsFUsZYqrPMyiwHjwRN9WvKm9incJ3AlaokdDIPjzPedoeRKErX6bMK4wRX3HzXA%5CFw6uCPkrBSCD%5C6JwvamGN%2BKBKTbiAnz%2Bji8qUS%5C%2F%2Be%3A1723367360700',
}

headers = {
    'authority': 'music.163.com',
    'accept': '*/*',
    'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
    'content-type': 'application/x-www-form-urlencoded',
    # 'cookie': '_ntes_nuid=399b5e331ec0413c5455353f1046477d; _iuqxldmzr_=32; NMTID=00OxQ0tD40btpDpiEN5qEuGUwKrZnkAAAGAfcSJcg; WEVNSM=1.0.0; WNMCID=ikvmkb.1651377473502.01.0; WM_TID=9FGbvXH8HeJFEQFVFQLFAG6joCCF2%2Bp%2B; _ntes_nnid=399b5e331ec0413c5455353f1046477d,1694477914286; ntes_utid=tid._.dNI4KmkFtAhAVlARUALQyZF5oUMNPBCs._.0; sDeviceId=YD-xxC57qOxaZ9ER1VVVBaRmV%2FBVOKVmHQ%2F; __snaker__id=NC0ojMWDUQmkBJm2; ntes_kaola_ad=1; __csrf=402eea0fef99183f935a2f8ee3da18d7; __csrf=3a3f7ea42a8cb890c88e96b81dfbfe4b; MUSIC_U=00AB1E0AA4CF807D344FAB25217502B73ED7A250C14DADF268E81455A1462D48A33A19E89CFE16C3E2A0F33C8FA62C643DD0D6AF1D135DF786A6530BA94B4012DDF28DCD60DD8407CB4D82FE4618CEDF80A505534B23FEB060359292BBF065EFB42D1CC8BD2C44F19B2D7C6506D19EE841DCBDC09FDAC8BF353C8CE734F4801BF201F34AE3F40CE112E3DE36F64C07B9F1A050A4CAD9FC0CE6F9ABFB6FD33561930D7A7BC74A43EB6FA7404074709EE6BFDEFF0B3B5305250D2FC6351FE299B62D63A4C378FE8122EB85D010A2EF478D1CE0A264D7431EE1C9692F0212E22172EA328885AF2B00F91A92124154F1A870299591B8E83A934511D786BA2F5775377EEFD486009018B99E41712A19873A0847BC51E888DB44D2A37A554DE554A8FA5E78034D09DCABC96619382546CA96EF3C70D03F156F9FE21CB50CE66F0B3B49694802D8A72332F63D47547C13622ECC4FCC1F66C9F8D152AFF629116D9E20DED456EADDDFD2A7E9984A38BCBD0EAD6A25; gdxidpyhxdE=5hpRbSBHDoQhpWQ%2Bhe01CX0N%2B5M5tiUAWgw%5Cz%5C%2B1GCkTXAmcxaCtPMhfjOKZu%2BZlBgHgOkqKNhyy9bh%5C5QA%2FGfD%2B6X9Q9Xsr4cqeE9wX%2BMQQe0VGhYZOq2E8hu4Vu%2FE8WARcZQo8MgsCwcE1sYPgULNiEyLq%2BvLuAt%5CPBriqjUoCMxoa%3A1723273134032; WM_NI=YQNVwo63RLwulcNO9NreUOOTYDlodVZyKI8npBS2pkWCe3KFyX1xPrye70Oz7eMymT3F8EEBuFtR5%2FJGh1UZimFQuGOBCfWYAxpupJOKnndZucZoCz90MJH86yvb4sPcT2Y%3D; WM_NIKE=9ca17ae2e6ffcda170e2e6ee8dd872ba968bccaa7090868fa3c45f829e8e87cb5eab9e8eadf44392aba9a9f82af0fea7c3b92a9b8f82b7f665f6ed9eadf67fb0bd82b0bc46b2bb9bb0ce609b9ca490e75e9aa785aabb66b49e9dd3f361959dabd4ca4ebb88ff99d37abbbbf9d1ce72f5bb839af060f19af8a6c84ab79abcb3b8258a99a8d2d852abb38ab2f84d8d9e8d87d65383a8c096f3428d95a28fe752b7bd9690c272fbf083abcb34f6a7ba83b77994bd9cd3dc37e2a3; JSESSIONID-WYYY=UnFqYjUFTeO4jjrb3T5ml1CFqSnpH3nuyH2rR5gSDS3szWl2%2F0DZSE3%2FQuBF4KjAmnovnMsFUsZYqrPMyiwHjwRN9WvKm9incJ3AlaokdDIPjzPedoeRKErX6bMK4wRX3HzXA%5CFw6uCPkrBSCD%5C6JwvamGN%2BKBKTbiAnz%2Bji8qUS%5C%2F%2Be%3A1723367360700',
    'origin': 'https://music.163.com',
    'referer': 'https://music.163.com/',
    'sec-ch-ua': '"Chromium";v="122", "Not(A:Brand";v="24", "Microsoft Edge";v="122"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'same-origin',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0',
}

params = {
    'csrf_token': '402eea0fef99183f935a2f8ee3da18d7',
}

data = {
    'params': res['encText'],
    'encSecKey': res['encSecKey'],
}

response = requests.post(
    'https://music.163.com/weapi/song/enhance/player/url/v1',
    params=params,
    cookies=cookies,
    headers=headers,
    data=data,
).text

print(response)